package com.example.demo.service.aliyun.message;

import com.alibaba.dubbo.config.annotation.Service;
import com.cclub.inteface.model.messageTemplateBO;
import com.cclub.inteface.service.common.message;
import com.example.demo.config.MessageConfig;
import com.example.demo.service.mq.rabbitmq.RabbitmqServiceImpl;
import com.example.demo.constant.mqConstant;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;
import java.util.List;

@Component
@Service(version = "1.0.0",interfaceClass = message.class)
@RequiredArgsConstructor
public class messageService implements message{

    @NonNull
    private RabbitmqServiceImpl rabbitmqService;

    @NonNull
    private ObjectMapper objectMapper;

    @NonNull
    private MessageConfig messageConfig;
    @Override
    public void sendMessage(List<messageTemplateBO> list) throws JsonProcessingException{
        for(messageTemplateBO bo :list){
            rabbitmqService.sendWork(mqConstant.shortMessageMqName,objectMapper.writeValueAsString(bo));
        }
    }
}
